﻿using System;
using System.Collections.Generic;
using SharpSqlAnalyzer.nodes;
using SharpSqlAnalyzer.nodes.hive;

namespace SharpSqlAnalyzer.stmt
{
	// Token: 0x0200007C RID: 124
	public class TAlterDatabaseStmt : TCustomSqlStatement
	{
		// Token: 0x17000045 RID: 69
		// (get) Token: 0x060002F7 RID: 759 RVA: 0x002F9492 File Offset: 0x002F7692
		// (set) Token: 0x060002F8 RID: 760 RVA: 0x002F949A File Offset: 0x002F769A
		public virtual TObjectName NewDatabaseName
		{
			get
			{
				return this.newDatabaseName;
			}
			set
			{
				this.newDatabaseName = value;
			}
		}

		// Token: 0x17000046 RID: 70
		// (get) Token: 0x060002F9 RID: 761 RVA: 0x002F94A3 File Offset: 0x002F76A3
		// (set) Token: 0x060002FA RID: 762 RVA: 0x002F94AB File Offset: 0x002F76AB
		public virtual TObjectName OwnerName
		{
			get
			{
				return this.ownerName;
			}
			set
			{
				this.ownerName = value;
			}
		}

		// Token: 0x17000047 RID: 71
		// (get) Token: 0x060002FB RID: 763 RVA: 0x002F94B4 File Offset: 0x002F76B4
		// (set) Token: 0x060002FC RID: 764 RVA: 0x002F94BC File Offset: 0x002F76BC
		public virtual TObjectName DatabaseName
		{
			get
			{
				return this.databaseName;
			}
			set
			{
				this.databaseName = value;
			}
		}

		// Token: 0x17000048 RID: 72
		// (get) Token: 0x060002FD RID: 765 RVA: 0x002F94C5 File Offset: 0x002F76C5
		// (set) Token: 0x060002FE RID: 766 RVA: 0x002F94CD File Offset: 0x002F76CD
		public virtual List<THiveKeyValueProperty> DbProperties
		{
			get
			{
				return this.dbProperties;
			}
			set
			{
				this.dbProperties = value;
			}
		}

		// Token: 0x060002FF RID: 767 RVA: 0x002F94D6 File Offset: 0x002F76D6
		public TAlterDatabaseStmt(EDbVendor dbvendor) : base(dbvendor)
		{
			this.sqlstatementtype = ESqlStatementType.sstalterdatabase;
		}

		// Token: 0x06000300 RID: 768 RVA: 0x002F94E8 File Offset: 0x002F76E8
		public override int doParseStatement(TCustomSqlStatement psql)
		{
			if (this.rootNode == null)
			{
				return -1;
			}
			base.doParseStatement(psql);
			TAlterDatabaseSqlNode talterDatabaseSqlNode = (TAlterDatabaseSqlNode)this.rootNode;
			this.databaseName = talterDatabaseSqlNode.DatabaseName;
			base.DatabaseObjects.Add(this.databaseName);
			this.dbProperties = talterDatabaseSqlNode.DbProperties;
			if (this.dbvendor == EDbVendor.dbvmssql)
			{
				bool flag = false;
				for (int i = 0; i < this.sourcetokenlist.size(); i++)
				{
					TSourceToken tsourceToken = this.sourcetokenlist.get(i);
					if (tsourceToken.tokencode == 425)
					{
						flag = true;
					}
					else if (flag && tsourceToken.tokencode != 259)
					{
						this.databaseName = new TObjectName();
						this.databaseName.init(tsourceToken);
						break;
					}
				}
			}
			else if (this.dbvendor == EDbVendor.dbvredshift)
			{
				this.newDatabaseName = talterDatabaseSqlNode.NewDatabaseName;
				this.ownerName = talterDatabaseSqlNode.OwnerName;
			}
			return 0;
		}

		// Token: 0x06000301 RID: 769 RVA: 0x002F95CC File Offset: 0x002F77CC
		public override void accept(TParseTreeVisitor v)
		{
			v.preVisit(this);
			v.postVisit(this);
		}

		// Token: 0x06000302 RID: 770 RVA: 0x002F95DC File Offset: 0x002F77DC
		public virtual void acceptChildern(TParseTreeVisitor v)
		{
			v.preVisit(this);
			v.postVisit(this);
		}

		// Token: 0x0400108F RID: 4239
		private TObjectName databaseName;

		// Token: 0x04001090 RID: 4240
		private List<THiveKeyValueProperty> dbProperties;

		// Token: 0x04001091 RID: 4241
		private TObjectName newDatabaseName;

		// Token: 0x04001092 RID: 4242
		private TObjectName ownerName;
	}
}
